<?php
namespace app\api\controller;
use think\Controller;
use api\UserService;
use app\common\service\SmsService;
use app\common\service\MailService;
use think\Cache;

class Index extends Controller
{
	
	
	/**
	 * @api {get} /index/school 获取默认参赛学校
	 * @apiVersion 1.0.0
	 * @apiName school
	 * @apiGroup index
	 *
	 * @apiDescription 获取默认参赛学校
	 *
	 * @apiParam {String} token 登录授权token
	 *
	 * @apiError 20000 请求参数错误
	 *
	 * @apiErrorExample Response (example):
	 *     {
	 *		  "code": 99999,
	 *		  "data": {
	 *		    "schoolId": "16670",
	 *		    "schoolName": "安外大街小学"
	 *		  }
	 *		}
	 */
 	public function test($id)
    {
    	echo UserService::getInstance()->getUserName();die;
    	echo $id;die;
    }
    
    public function sendcode(){
    	$result = SmsService::getInstance()->setAdapter('Guodu')->sendCode('18515019527', 'register');
    	return json($result);
    }
    
    public function sendmail(){
    	$touser = "945558163@qq.com";
    	$title  = "邮件测试";
    	$body   = "这是一封测试邮件";
    	$result = MailService::getInstance()->sendmail($touser, $title, $body);
    	return json($result);
    }
    
    public function cache(){
    	$key = "cache_key";
    	Cache::store('redis')->set($key,"this is redis",600);
    	Cache::store('file')->set($key,"this is file",600);
    	Cache::store('memcache')->set($key,"this is memcache",600);
    	$redis_name = Cache::store('redis')->get($key);
    	$file_name = Cache::store('file')->get($key);
    	$memcache_name = Cache::store('memcache')->get($key);
    	var_dump($redis_name,$file_name,$memcache_name);die;
    }
    
  
}
